package com.examine.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class DataConfig {

    private static SqlSessionFactory sqlSessionFactory = null;
    private static SqlSession session = null;

    public static SqlSession getSession(){
        try{

            String resource = "config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            session = sqlSessionFactory.openSession();

        }catch(Exception e){
            e.printStackTrace();
        }
        return session;
    }

}
